<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- ### 练习题1：
    用户输入一个数值，去数组中寻找该数的下标，有则打印该数第一次出现的下标，没有则打印-1
    * 例如: [88,20,10,100,50]  打印 2
    * 例如: [88,20,30,100,50]  打印-1 -->

    <script>
        let num = +prompt('请输入一个数')

        let arr = [88, 20, 10, 100, 50];

        let xxm = -1;

        for (let i = 0; i < arr.length; i++) {
            if (arr[i] === num) {
                xxm = i
                break;
            }
        }
        console.log(xxm)
    </script>
</body>

</html>